import pygame


class quan_var:#  全局变量类
    map_dict={(0, 4): 2, (0, 5): 2, (1, 4): 2, (1, 5): 2, (2, 2): 2, (2, 3): 2, (3, 2): 2, (3, 3): 2, (2, 6): 2,
              (2, 7): 2, (3, 6): 2, (3, 7): 2, (8, 18): 2, (8, 19): 2, (9, 18): 2, (14, 4): 2, (14, 5): 2, (15, 4): 2,
              (15, 5): 2, (9, 19): 2, (20, 20): 2, (20, 21): 2, (20, 22): 2, (20, 23): 2, (21, 20): 2, (21, 21): 2,
              (21, 22): 2, (21, 23): 2, (22, 20): 2, (22, 21): 2, (23, 20): 2, (23, 21): 2, (4, 4): 2, (4, 5): 2, (4, 8): 2,
              (4, 9): 2, (4, 12): 2, (4, 13): 2, (4, 14): 2, (4, 15): 2, (4, 18): 2, (4, 19): 2, (5, 4): 2, (5, 5): 2, (5, 8): 2,
              (5, 9): 2, (5, 12): 2, (5, 13): 2, (5, 14): 2, (5, 15): 2, (5, 18): 2, (5, 19): 2, (6, 6): 2, (6, 7): 2, (6, 12): 2,
              (6, 13): 2, (6, 18): 2, (6, 19): 2, (7, 6): 2, (7, 7): 2, (7, 12): 2, (7, 13): 2, (7, 18): 2, (7, 19): 2, (10, 12): 2,
              (10, 13): 2, (10, 14): 2, (10, 15): 2, (10, 16): 2, (10, 17): 2, (10, 18): 2, (10, 19): 2, (11, 12): 2, (11, 13): 2,
              (11, 14): 2, (11, 15): 2, (11, 16): 2, (11, 17): 2, (11, 18): 2, (11, 19): 2, (12, 4): 2, (12, 5): 2, (12, 6): 2,
              (12, 7): 2, (12, 8): 2, (12, 9): 2, (12, 10): 2, (12, 11): 2, (13, 4): 2, (13, 5): 2, (13, 6): 2, (13, 7): 2,
              (13, 8): 2, (13, 9): 2, (13, 10): 2, (13, 11): 2, (16, 4): 2, (16, 5): 2, (16, 10): 2, (16, 11): 2, (16, 16): 2,
              (16, 17): 2, (16, 18): 2, (16, 19): 2, (17, 4): 2, (17, 5): 2, (17, 10): 2, (17, 11): 2, (17, 16): 2, (17, 17): 2,
              (17, 18): 2, (17, 19): 2, (18, 4): 2, (18, 5): 2, (18, 6): 2, (18, 7): 2, (18, 8): 2, (18, 9): 2, (18, 10): 2,
              (18, 11): 2, (18, 16): 2, (18, 17): 2, (19, 4): 2, (19, 5): 2, (19, 6): 2, (19, 7): 2, (19, 8): 2, (19, 9): 2,
              (19, 10): 2, (19, 11): 2, (19, 16): 2, (19, 17): 2, (0, 16): 3, (0, 17): 3, (0, 18): 3, (0, 19): 3, (0, 20): 3,
              (0, 21): 3, (1, 16): 3, (1, 17): 3, (1, 18): 3, (1, 19): 3, (1, 20): 3, (1, 21): 3, (2, 16): 3, (2, 17): 3,
              (2, 22): 3, (2, 23): 3, (3, 16): 3, (3, 17): 3, (3, 22): 3, (3, 23): 3, (4, 16): 3, (4, 17): 3, (4, 22): 3,
              (4, 23): 3, (5, 16): 3, (5, 17): 3, (5, 22): 3, (5, 23): 3, (6, 20): 3, (6, 21): 3, (6, 22): 3, (6, 23): 3,
              (7, 20): 3, (7, 21): 3, (7, 22): 3, (7, 23): 3, (8, 10): 3, (8, 11): 3, (8, 12): 3, (8, 13): 3, (9, 10): 3,
              (9, 11): 3, (9, 12): 3, (9, 13): 3, (10, 8): 3, (10, 9): 3, (11, 8): 3, (11, 9): 3, (12, 14): 3, (12, 15): 3,
              (13, 14): 3, (13, 15): 3, (14, 10): 3, (14, 11): 3, (14, 12): 3, (14, 13): 3, (15, 10): 3, (15, 11): 3, (15, 12): 3,
              (15, 13): 3, (16, 0): 3, (16, 1): 3, (16, 2): 3, (16, 3): 3, (17, 0): 3, (17, 1): 3, (17, 2): 3, (17, 3): 3,
              (18, 0): 3, (18, 1): 3, (18, 18): 3, (18, 19): 3, (18, 20): 3, (18, 21): 3, (19, 0): 3, (19, 1): 3, (19, 18): 3,
              (19, 19): 3, (19, 20): 3, (19, 21): 3, (20, 0): 3, (20, 1): 3, (20, 6): 3, (20, 7): 3, (20, 18): 3, (20, 19): 3,
              (21, 0): 3, (21, 1): 3, (21, 6): 3, (21, 7): 3, (21, 18): 3, (21, 19): 3, (22, 2): 3, (22, 3): 3, (22, 4): 3,
              (22, 5): 3, (22, 6): 3, (22, 7): 3, (22, 22): 3, (22, 23): 3, (22, 24): 3, (22, 25): 3, (23, 2): 3, (23, 3): 3,
              (23, 4): 3, (23, 5): 3, (23, 6): 3, (23, 7): 3, (23, 22): 3, (23, 23): 3, (23, 24): 3, (23, 25): 3, (24, 22): 3,
              (24, 23): 3, (24, 24): 3, (24, 25): 3, (25, 22): 3, (25, 23): 3, (25, 24): 3, (25, 25): 3, (2, 4): 1, (2, 5): 1,
              (3, 4): 1, (3, 5): 1, (4, 6): 1, (4, 7): 1, (5, 6): 1, (5, 7): 1, (0, 22): 1, (0, 23): 1, (1, 22): 1, (1, 23): 1,
              (6, 16): 1, (6, 17): 1, (7, 17): 1, (7, 16): 1, (16, 6): 1, (16, 7): 1, (17, 6): 1, (17, 7): 1, (22, 0): 1,
              (22, 1): 1, (23, 0): 1, (23, 1): 1, (8, 8): 1, (8, 9): 1, (8, 14): 1, (8, 15): 1, (9, 8): 1, (9, 9): 1, (9, 14): 1,
              (9, 15): 1, (14, 8): 1, (14, 9): 1, (14, 14): 1, (14, 15): 1, (15, 8): 1, (15, 9): 1, (15, 14): 1, (15, 15): 1,
              (11, 23): 2, (12, 23): 2, (13, 23): 2, (14, 23): 2, (11, 24): 2, (14, 24): 2, (11, 25): 2, (14, 25): 2, (12, 24): 4,
              (13, 24): 4, (12, 25): 4, (13, 25): 4}  # 地图初始坐标 生成 1 2 3 4
    tree = 1     #  表示为树木
    brick = 2    #  表示为土砖
    iron = 3     #  表示为刚墙
    home = 4     #  表示为老鹰
    mytank = 5   #  标记我方坦克
    enytank = 6  #  敌方坦克
    enytank_num = 3  #  敌方坦克总数，最少设置为三
    now_enytank_num = 0  #  此时地图上存在的地方坦克数
    mytank_life = 3  #  我方坦克初始生命值
    static_obj = {}  #  存放不动控件的位置与对象
    mytank_dict = {}  #  存放我方坦克对象
    food_dict = {}  #  存放食物位置：对象
    enytank_dict = {}  #  存放敌方坦克   存放形式为 {（此时坦克像素坐标）：敌方坦克对象}
    bullet_type_dict = {}
    mytank_speed = 24  #  我方坦克速度
    laoying = None   #  老鹰对象
    main_obj = None  #  主界面对象
    food_obj = None  #  食物对象
    thread_life = False  #  我方坦克子弹线程标志位，False表示为线程不在运行
    frame_one = None   #  主界面上的第一层框架
    life_list = {}  #  存放坦克   坦克对象：显示生命值的控件对象
    fenshu = 0   #  游戏总分数
    #  加载音效
    pygame.init()
    pygame.mixer.init()
    volume = 1
    # 子弹爆炸音效
    bang_sound = pygame.mixer.Sound("./audios/bang.wav")
    bang_sound.set_volume(volume*0.2)
    # 游戏开始等声音
    start_sound = pygame.mixer.Sound("./audios/start.wav")
    start_sound.set_volume(volume*0.6)
    # 游戏胜利的声音
    win_music = pygame.mixer.Sound("./audios/victory.wav")
    win_music.set_volume(volume)
    # 游戏失败的声音
    defeat = pygame.mixer.Sound("./audios/sb2.wav")
    defeat.set_volume(volume)
    #  玩家获得事物的声音
    add_food = pygame.mixer.Sound("./audios/add.wav")
    add_food.set_volume(volume)